
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region CityDAL
	public class CityDAL : DBContext
	{
		public List<City> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CitiesSelectAll");
            return GetEntityList<City>(cmd);
        }

        public City GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CitySelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<City>(cmd);
        }

		public List<City> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CitySelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<City>(cmd);
        }
        public City Add(string paramName, string paramDescription, int paramCountryId, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CityInsert");
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Description", paramDescription);
            cmd.AddParameter("@CountryId", paramCountryId);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<City>(cmd);
        }

        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CityDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public City UpdateById(Guid paramId, string paramName, string paramDescription, int paramCountryId,	string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CityUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Description", paramDescription);
			cmd.AddParameter("@CountryId", paramCountryId);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<City>(cmd);
        }
		
	}
	#endregion
}
